import request from '@/axios'
import type { LoginUserType, UserInfoType } from './types'

//用户登录接口
export const loginApi = (data: any): Promise<IResponse<LoginUserType>> => {
  return request.post({ url: '/rbac-server/rbac/login/submit', data })
}

//用户登出接口
export const loginOutApi = (): Promise<IResponse> => {
  return request.get({ url: '/rbac-server/rbac/login/loginOut' })
}

export const getUserListApi = ({ params }: AxiosConfig) => {
  return request.get<{
    code: string
    data: {
      list: UserInfoType[]
      total: number
    }
  }>({ url: '/mock/user/list', params })
}

//获取可访问资源接口
export const getResourceApi = (systemId: string): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
  return request.get({ url: '/rbac-server/rbac/permission/route', params: { systemId } })
}
